var Cesium = require('cesium/Cesium')

const LayerOptions = [
    {
        id: 1,
        name: '影像图',
        img: require('../../assets/img/baseLayer (1).png'),
        imageryProvider: [
            new Cesium.WebMapTileServiceImageryProvider({
                url: "http://t0.tianditu.com/img_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=4676cbcd5a7b93b0e7f4ab6f6a4f8fec",
                layer: "tiandituImg",
                style: "default",
                format: "image/jpeg",
                tileMatrixSetID: "tiandituImg",
                show: true,
                maximumLevel: 18
            }),
            new Cesium.WebMapTileServiceImageryProvider({
                //影像注记
                url: "http://t{s}.tianditu.com/cia_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=cia&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default.jpg&tk=4676cbcd5a7b93b0e7f4ab6f6a4f8fec",
                subdomains: ["0", "1", "2", "3", "4", "5", "6", "7"], // ["t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7"],
                layer: "tdtCiaLayer",
                style: "default",
                format: "image/jpeg",
                tileMatrixSetID: "GoogleMapsCompatible",
                show: true,
            }),
        ]

    },
    // {
    //     id: 2,
    //     name: '矢量底图',
    //     img: require('../../assets/img/baseLayer (2).png'),
    //     imageryProvider:
    //         new Cesium.WebMapTileServiceImageryProvider({
    //             url: "http://t0.tianditu.gov.cn/vec_c/wmts?tk=a9046b1c5cd454b6f56c2644e97c0df0",
    //             layer: "tiandituImg",
    //             style: "default",
    //             format: "image/jpeg",
    //             tileMatrixSetID: "tiandituImg",
    //             show: true,
    //             maximumLevel: 18
    //         })
    // },
    {
        id: 2,
        name: '矢量图',
        img: require('../../assets/img/baseLayer (2).png'),
        imageryProvider: [
            new Cesium.WebMapTileServiceImageryProvider({
                url: "http://t0.tianditu.gov.cn/vec_c/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=4676cbcd5a7b93b0e7f4ab6f6a4f8fec",
                layer: "tiandituImg",
                style: "default",
                format: "image/jpeg",
                tileMatrixSetID: "tiandituImg",
                show: true,
                maximumLevel: 18
            }),
            new Cesium.WebMapTileServiceImageryProvider({
                //影像注记
                url: "http://t{s}.tianditu.com/cia_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=cia&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default.jpg&tk=4676cbcd5a7b93b0e7f4ab6f6a4f8fec",
                subdomains: ["0", "1", "2", "3", "4", "5", "6", "7"], // ["t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7"],
                layer: "tdtCiaLayer",
                style: "default",
                format: "image/jpeg",
                tileMatrixSetID: "GoogleMapsCompatible",
                show: true,
            }),
        ]
    },
    // {
    //     id: 3,
    //     name: '高德底图',
    //     img: require('../../assets/img/baseLayer (3).png'),
    //     imageryProvider: new Cesium.UrlTemplateImageryProvider({
    //         url: "https://webst02.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",
    //         layer: "tdtVecBasicLayer",
    //         style: "default",
    //         format: "image/png",
    //         tileMatrixSetID: "GoogleMapsCompatible",
    //         show: true,
    //     })
    // },
    // {
    //     id: 3,
    //     name: '网格',
    //     imageryProvider: new Cesium.GridImageryProvider()
    // },
    // {
    //     id: 4,
    //     name: 'ArcGis底图',
    //     img: require('../../assets/img/baseLayer (4).png'),
    //     imageryProvider: new Cesium.ArcGisMapServerImageryProvider({
    //         url: "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer?f=jsapi",
    //         maximumLevel: 23,//图层显示的最大的层级，确定图层的精细度
    //     })
    // },
    // {
    //     id: 1,
    //     name: '底图',
    //     collapseIndex: 1,
    //     imagProviders: [
    //         {
    //             id: 1,
    //             name: '天地图',
    //             imageryProvider:
    //                 new Cesium.WebMapTileServiceImageryProvider({
    //                     url: "http://t0.tianditu.com/img_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=4676cbcd5a7b93b0e7f4ab6f6a4f8fec",
    //                     layer: "tiandituImg",
    //                     style: "default",
    //                     format: "image/jpeg",
    //                     tileMatrixSetID: "tiandituImg",
    //                     show: true,
    //                     maximumLevel: 18
    //                 })
    //             //   new Cesium.WebMapTileServiceImageryProvider({
    //             //     url: "http://t0.tianditu.com/img_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=ebf64362215c081f8317203220f133eb",
    //             //     layer: "tdtBasicLayer",
    //             //     style: "default",
    //             //     format: "image/jpeg",
    //             //     tileMatrixSetID: "GoogleMapsCompatible",
    //             //     show: false
    //             // })
    //         },
    //         {
    //             id: 2,
    //             name: '高德地图',
    //             imageryProvider: new Cesium.UrlTemplateImageryProvider({
    //                 url: "https://webst02.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",
    //                 layer: "tdtVecBasicLayer",
    //                 style: "default",
    //                 format: "image/png",
    //                 tileMatrixSetID: "GoogleMapsCompatible",
    //                 show: true,
    //             })
    //         },
    //         {
    //             id: 3,
    //             name: '网格',
    //             imageryProvider: new Cesium.GridImageryProvider()
    //         },
    //         {
    //             id: 4,
    //             name: 'ArcGis',
    //             imageryProvider: new Cesium.ArcGisMapServerImageryProvider({
    //                 url: "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer?f=jsapi",
    //                 maximumLevel: 23,//图层显示的最大的层级，确定图层的精细度
    //             })
    //         },
    //     ]
    // },
    // {
    //     id: 2,
    //     name: '影像图',
    //     collapseIndex: 2,
    //     imagProviders: [
    //         {
    //             id: 21,
    //             name: '影像图1',
    //             imageryProvider: null
    //         },
    //         {
    //             id: 22,
    //             name: '影像图2',
    //             imageryProvider: null
    //         },
    //         {
    //             id: 23,
    //             name: '影像图3',
    //             imageryProvider: null
    //         }
    //     ],
    // }

];
function BaiduImageryProvider(options) {



    this._errorEvent = new Cesium.Event();
    this._tileWidth = 256;
    this._tileHeight = 256;
    this._maximumLevel = 18;
    this._minimumLevel = 1;
    var southwestInMeters = new Cesium.Cartesian2(-33554054, -33746824);
    var northeastInMeters = new Cesium.Cartesian2(33554054, 33746824);
    this._tilingScheme = new Cesium.WebMercatorTilingScheme({



        rectangleSouthwestInMeters: southwestInMeters,
        rectangleNortheastInMeters: northeastInMeters
    });
    this._rectangle = this._tilingScheme.rectangle;
    var resource = Cesium.Resource.createIfNeeded(options.url);
    this._resource = resource;
    this._tileDiscardPolicy = undefined;
    this._credit = undefined;
    this._readyPromise = undefined;
}

Object.defineProperties(BaiduImageryProvider.prototype, {



    url: {



        get: function () {



            return this._resource.url;
        }
    },
    proxy: {



        get: function () {



            return this._resource.proxy;
        }
    },
    tileWidth: {



        get: function () {



            if (!this.ready) {



                throw new Cesium.DeveloperError('tileWidth must not be called before the imagery provider is ready.');
            }
            return this._tileWidth;
        }
    },

    tileHeight: {



        get: function () {



            if (!this.ready) {



                throw new Cesium.DeveloperError('tileHeight must not be called before the imagery provider is ready.');
            }
            return this._tileHeight;
        }
    },

    maximumLevel: {



        get: function () {



            if (!this.ready) {



                throw new Cesium.DeveloperError('maximumLevel must not be called before the imagery provider is ready.');
            }
            return this._maximumLevel;
        }
    },

    minimumLevel: {



        get: function () {



            if (!this.ready) {



                throw new Cesium.DeveloperError('minimumLevel must not be called before the imagery provider is ready.');
            }
            return this._minimumLevel;
        }
    },

    tilingScheme: {



        get: function () {



            if (!this.ready) {



                throw new Cesium.DeveloperError('tilingScheme must not be called before the imagery provider is ready.');
            }
            return this._tilingScheme;
        }
    },

    tileDiscardPolicy: {



        get: function () {



            if (!this.ready) {



                throw new Cesium.DeveloperError('tileDiscardPolicy must not be called before the imagery provider is ready.');
            }
            return this._tileDiscardPolicy;
        }
    },

    rectangle: {



        get: function () {



            if (!this.ready) {



                throw new Cesium.DeveloperError('rectangle must not be called before the imagery provider is ready.');
            }
            return this._rectangle;
        }
    },

    errorEvent: {



        get: function () {



            return this._errorEvent;
        }
    },
    ready: {



        get: function () {



            return this._resource;
        }
    },
    readyPromise: {



        get: function () {



            return this._readyPromise;
        }
    },
    credit: {



        get: function () {



            if (!this.ready) {



                throw new Cesium.DeveloperError('credit must not be called before the imagery provider is ready.');
            }
            return this._credit;
        }
    },
});

BaiduImageryProvider.prototype.requestImage = function (x, y, level, request) {
    var r = this._tilingScheme.getNumberOfXTilesAtLevel(level);
    var c = this._tilingScheme.getNumberOfYTilesAtLevel(level);
    var s = this.url.replace("{x}", x - r / 2).replace("{y}", c / 2 - y - 1).replace("{z}", level).replace("{s}", Math.floor(10 * Math.random()));
    return Cesium.ImageryProvider.loadImage(this, s);
};



export default LayerOptions

